<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<style>
	.superviseTd {
		cursor:	pointer;
	}
</style>
<div id="projSuperviseList" class="doclist" style="width:1400px;">

<div class="tableTitle">项目管理</div>
<table class="listTable cssrain">
	<thead>
		<tr>
			<th colspan="3">
				<input type="button" id="newDoc" value="新增"/>
				<input type="button" id="delDocs" value="删除" disabled="disabled"/>
			</th>
			<th colspan="9">
				<input type="text" size="40"/>
				<input type="button" value="查询"/>
				<input type="button" value="高级查询"/>
			</th>
		</tr>
		<tr>
			<th rowspan="2" style="width:25px;"><input id="checkboxAll" type="checkbox"/></th>
			<th rowspan="2" style="width:800px;">项目名称</th>
			<th rowspan="2" style="width:800px;">建设单位</th>
			<th colspan="8" style="text-align: center">项目审批情况</th>
			<th rowspan="2" style="width:400px;">自查问题</th>
		</tr>
		<tr>
			<th style="width:150px;">立项时间</th>
			<th style="width:200px;">立项批准文号</th>
			<th style="width:200px;">环评批准文号</th>
			<th style="width:200px;">规划批准文号</th>
			<th style="width:200px;">用地批准文号</th>
			<th style="width:200px;">施工批准文号</th>
			<th style="width:200px;">物资采购批准文号</th>
			<th style="width:200px;">中标文号</th>
			
		</tr>
	</thead>
	<tbody></tbody>
</table>
<div class="pages">
	<div class="pagesL">&nbsp;&nbsp;&nbsp;&nbsp;共<strong id="total"> 180</strong> 条记录&nbsp;&nbsp;<strong> 15</strong> 条/页，当前第<strong> 1</strong> 页</div>
	<div class="pagesC">◀◀上一页&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;2&nbsp;3&nbsp;4&nbsp;5&nbsp;...&nbsp;10&nbsp;&nbsp;&nbsp;&nbsp;下一页▶▶</div>
	<div class="pagesR">转到&nbsp; <input type="text" style="width:25px; height:12px; font-size:12px; border:solid 1px #7aaebd;"/>&nbsp;&nbsp;页&nbsp;&nbsp;&nbsp;</div>
</div>

<script type="text/javascript">
	// For Demo
	tbodyHtml = "";
	var doc;
	var today = new Date();
	var count = 0;
	for (var id in window.memDocs) {
		if (count < 15) {		
			doc = window.memDocs[id];
			if (!doc)
				continue;
			
			tbodyHtml += "<tr><td><input type='checkbox' class='recSelect' value='"+id+"'/>"
				+"</td><td><a class='viewProj'>"+doc.projName
				+"</a></td><td>"+doc.projOrg
				+"</td><td>"+doc.setupDate.toStdDateString()
				+"</td><td>"+doc.approveNum
				+"</td>";

			/**
			 *	环保批准
			 */
			var envApproveList = window.parent.mem.envApprove;
			if (envApproveList[id]) {
				var approves = envApproveList[id];
				var approve, lastAppr = null;
				for (var seq in approves) {
					approve = approves[seq];
					
					if (!lastAppr || approve.approveDate > lastAppr.approveDate) {
						lastAppr = approve;
					}
				}
				approve = lastAppr;
				
				if (approve.verified) {
					tbodyHtml += '<td class="projApprVerified superviseTd supervise" alt="'+approve.approveDate+'">'+approve.approveNum
						+"</td>";
				} else {
					tbodyHtml += '<td class="projApprUnverified superviseTd supervise" alt="'+approve.approveDate+'">'+approve.approveNum
						+"</td>";
				}
			} else {
				tbodyHtml += '<td class="superviseTd supervise"></td>';
			}

			/**
			 *	规划批准
			 */
			var planApproveList = window.parent.mem.planApprove;
			if (planApproveList[id]) {
				var approves = planApproveList[id];
				var approve, lastAppr = null;
				for (var seq in approves) {
					approve = approves[seq];
					
					if (!lastAppr || approve.approveDate > lastAppr.approveDate) {
						lastAppr = approve;
					}
				}
				approve = lastAppr;

				if (approve.verified) {
					tbodyHtml += '<td class="projApprVerified superviseTd supervise" alt="'+approve.approveDate+'">'+approve.approveNum
						+"</td>";
				} else {
					tbodyHtml += '<td class="projApprUnverified superviseTd supervise" alt="'+approve.approveDate+'">'+approve.approveNum
						+"</td>";
				}
			} else {
				tbodyHtml += '<td class="superviseTd supervise"></td>'
			}

			/**
			 *	用地批准
			 */
			var landApproveList = window.parent.mem.landApprove;
			if (landApproveList[id]) {
				var approves = landApproveList[id];
				var approve, lastAppr = null;
				for (var seq in approves) {
					approve = approves[seq];
					
					if (!lastAppr || approve.approveDate > lastAppr.approveDate) {
						lastAppr = approve;
					}
				}
				approve = lastAppr;

				if (approve.verified) {
					tbodyHtml += '<td class="projApprVerified superviseTd supervise" alt="'+approve.approveDate+'">'+approve.approveNum
						+"</td>";
				} else {
					tbodyHtml += '<td class="projApprUnverified superviseTd supervise" alt="'+approve.approveDate+'">'+approve.approveNum
						+"</td>";
				}
			} else {
				tbodyHtml += '<td class="superviseTd supervise"></td>'
			}

			/**
			 *	施工批准
			 */
			var constrApproveList = window.parent.mem.constrApprove;
			if (constrApproveList[id]) {
				var approves = constrApproveList[id];
				var approve, lastAppr = null;
				for (var seq in approves) {
					approve = approves[seq];
					
					if (!lastAppr || approve.approveDate > lastAppr.approveDate) {
						lastAppr = approve;
					}
				}
				approve = lastAppr;

				if (approve.verified) {
					tbodyHtml += '<td class="projApprVerified superviseTd supervise" alt="'+approve.approveDate+'">'+approve.approveNum
						+"</td>";
				} else {
					tbodyHtml += '<td class="projApprUnverified superviseTd supervise" alt="'+approve.approveDate+'">'+approve.approveNum
						+"</td>";
				}
			} else {
				tbodyHtml += '<td class="superviseTd supervise"></td>';
			}

			/**
			 *	物资采购批准
			 */
			var purchaseApproveList = window.parent.mem.purchaseApprove;
			if (purchaseApproveList[id]) {
				var approves = purchaseApproveList[id];
				var approve, lastAppr = null;
				for (var seq in approves) {
					approve = approves[seq];
					
					if (!lastAppr || approve.approveDate > lastAppr.approveDate) {
						lastAppr = approve;
					}
				}
				approve = lastAppr;

				if (approve.verified) {
					tbodyHtml += '<td class="projApprVerified superviseTd supervise" alt="'+approve.approveDate+'">'+approve.approveNum
						+"</td>";
				} else {
					tbodyHtml += '<td class="projApprUnverified superviseTd supervise" alt="'+approve.approveDate+'">'+approve.approveNum
						+"</td>";
				}
			} else {
				tbodyHtml += '<td class="superviseTd supervise"></td>'
			}

			/**
			 *	中标文号
			 */
			var biddingApproveList = window.parent.mem.biddingApprove;
			if (biddingApproveList[id]) {
				var approves = biddingApproveList[id];
				var approve, lastAppr = null;
				for (var seq in approves) {
					approve = approves[seq];
					
					if (!lastAppr || approve.approveDate > lastAppr.approveDate) {
						lastAppr = approve;
					}
				}
				approve = lastAppr;

				if (approve.verified) {
					tbodyHtml += '<td class="projApprVerified superviseTd supervise" alt="'+approve.approveDate+'">'+approve.approveNum
						+"</td>";
				} else {
					tbodyHtml += '<td class="projApprUnverified superviseTd supervise" alt="'+approve.approveDate+'">'+approve.approveNum
						+"</td>";
				}
			} else {
				tbodyHtml += '<td class="superviseTd supervise"></td>'
			}

			tbodyHtml += '<td class="problemRecord"></td></tr>';
		}
		count++;
	}

	for (;count < 15; count++) {
		tbodyHtml += "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
	}
	
	$("#projSuperviseList > .listTable > tbody").html(tbodyHtml);
	$("#projSuperviseList > .pages > .pagesL > #total").html(count);
	
</script>
<script type="text/javascript" src="<%=basePath %>admin/js/table-chexkbox.js"></script>
<script type="text/javascript">

	$('.cssrain tbody').delegate("tr", "click", function() {
		if ($('.cssrain input[type="checkbox"]:checked').length > 0) {
			$("#delDocs").removeAttr("disabled");
		} else {
			$("#delDocs").attr("disabled", "disabled");
		}
	});

	$(".listTable").delegate("td.supervise", "click", function(evt) {
		var prid = $(evt.target).parent().find(".recSelect").val();
		$().simpleDialog({
			ajax:true,
			ajaxUrl:	"<%=basePath%>admin/superviseMgr.jsp?prid="+prid,
			title:	'工程建设项目管理',
			buttons:{'取消':function(){closeDialog();},'保存':function(){closeDialog();}}
		});
	});
	

	$("#delDocs").click(function() {
		if (!confirm("确定要删除所选文档吗？"))
			return false;

		$('.cssrain input[type="checkbox"]:checked').each(function(index, elem) {
			var id = $(elem).val();
			window.memDocs[id] = undefined;
		});
		
		$.simpleTip("成功删除");
		$("#manager").load("<%=basePath%>admin/attendInstList.jsp");
	});

	$(".viewProj").click(function (evt) {
		var prid = $(this).parents("tr").find('input.recSelect').val();

		$().simpleDialog({
			ajax:true,
			ajaxUrl:	"<%=basePath%>admin/projView.jsp?prid="+prid,
			title:	'查看项目信息',
			buttons:{'取消':function(){closeDialog();},'保存':function(){closeDialog();sucTip();}}
		});
		
	});

	$(".problemRecord").click(function() {

		$().simpleDialog({
			ajax:true,
			ajaxUrl:	"<%=basePath%>admin/problemList.jsp",
			title:	'自查问题',
			buttons:{'取消':function(){closeDialog();},'保存':function(){closeDialog();sucTip();}}
		});
	});
	
</script>
</div>